package com.school.test;

import com.school.entity.Student;
import com.school.entity.Teacher;
import com.school.entity.Course;

public class TestCourseSelection {
    public static void main(String[] args) {
        // 1. 创建课程对象（Course为default权限，同包com.school.entity内可直接创建）
        Course c1 = new Course("C001", "Java程序设计", "A101", "周二上午", "T001");
        Course c2 = new Course("C002", "数据库原理", "B202", "周四下午", "T002");

        // 2. 创建教师对象（子类继承父类属性，通过super初始化）
        Teacher t1 = new Teacher("T001", "索隆", "男");
        Teacher t2 = new Teacher("T002", "山治", "女");
        t1.openCourse(c1);
        t2.openCourse(c2);

        // 3. 创建学生对象
        Student s1 = new Student("S001", "艾斯", "男");
        Student s2 = new Student("S002", "萨博", "女");
        s1.selectCourse(c1);
        s1.selectCourse(c2);
        s2.selectCourse(c1);
        s1.dropCourse(c2);

        // 4. 测试重写方法：打印信息（子类重写父类printInfo()）
        System.out.println("\n===== 教师信息 =====");
        t1.printInfo();
        System.out.println("\n===== 学生信息 =====");
        s1.printInfo();
        s2.printInfo();

        // 5. 验证权限修饰符可见性
        System.out.println("\n===== 权限验证 =====");
        System.out.println("学生姓名（通过公共方法访问）：" + s1.getName());
        System.out.println("教师授课课程（protected属性，子类可访问）：" + t1.getCourse().getCourseName());
    }
}